package ying.filter;

import jakarta.servlet.*;

import java.io.IOException;

/**
 * ClassName: FilterDemo01
 * Package: ying.filter
 * Description:
 *
 * @Author 刘英杰
 * @Create 2024/10/6 10:03
 * @Version 1.0
 */
public class FilterDemo01 implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("FilterDemo01开始执行"+request+"..."+response);
        chain.doFilter(request, response);//一旦执行该方法,就相当于过滤器放行,去访问目标资源
        System.out.println("FilterDemo01结束执行");

        response.setContentType("text/html;charset=UTF-8");
        response.getWriter().write("FilterDemo01的响应");

    }
}
